package com.zjj.filmcommentapi.utils;

import java.io.*;
import java.util.Properties;

/**
 * 根据key读取value
 */
public class PropertiesUtil {
    public static String getProp(String key){
        Properties prop = new Properties();
        InputStream in = null;
        String file = "src/main/resources/config/config.properties";
        try{
            in = new BufferedInputStream(new FileInputStream(file));
            if (in!=null){
                prop.load(in);
            }
            return prop.getProperty(key);
        }catch (Exception e){
            System.out.println("读取配置config.properties异常"+e.getMessage());
            return null;
        }
        finally {
            try {
                if (in!=null){
                    in.close();
                }
            }catch (IOException e){
                System.out.println("IO异常"+e.getMessage());
            }
        }
    }
}
